/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.timesoft.hibernate.core;

import com.timesoft.common.core.CoreContent;
import com.timesoft.common.hibernate.TransactionalProcessor;
import com.timesoft.hibernate.bean.SettingFormatNumber;
import java.util.HashMap;
import org.apache.log4j.Logger;
import org.hibernate.Criteria;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.Transaction;

/**
 *
 * @author sorasaks
 */
public class SettingFormatNumberCore extends CoreContent {

    private static final Logger LOG = Logger.getLogger(SettingFormatNumberCore.class);

    public static SettingFormatNumber getSettingFormatNumber() {

        final HashMap param = new HashMap();
        new TransactionalProcessor() {

            @Override
            public void process(Session session, Transaction tx) {
                try {
                    Criteria criteria = session.createCriteria(SettingFormatNumber.class);
                    SettingFormatNumber setting = (SettingFormatNumber) criteria.uniqueResult();

                    LOG.info("::::::::::::::: setting :::::::::::::::" + setting);

                    param.put(VALUE, setting);
                } catch (HibernateException e) {
                    LOG.error(e.getMessage());
                    param.put(VALUE, null);
                }
            }
        }.process();
        return (SettingFormatNumber) param.get(VALUE);
    }
}
